<template>
  <div>
    <svg-icon :icon="isFullScrren ? 'exit-fullscreen' : 'fullscreen'" @click="onToggle" id="guide-full"></svg-icon>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import screenfull from 'screenfull'

const isFullScrren = ref(false)

// 监听变化
const change = () => {
  isFullScrren.value = screenfull.isFullscreen
}

// 切换事件
const onToggle = () => {
  screenfull.toggle()
}

// 设置侦听器
onMounted(() => {
  screenfull.on('change', change)
})

// 卸载侦听器
onUnmounted(() => {
  screenfull.off('change', change)
})
</script>

<style lang="scss" scoped>
</style>
